from flask import jsonify

from src.llm_apis.deepseek_service import call_deepseek_model
from src.llm_apis.openai_service import call_openai_model
from src.llm_apis.sparkai_service import call_sparkai_model
from src.llm_apis.zhipuai_service import call_zhipuai_model


def select_api(model_choice, gen_prompt):
    # 根据模型选择调用不同的函数
    """
    Call the appropriate model based on the user's choice.
    Args:
        model_choice (str): The chosen model, e.g., "GPT-3.5" or "Spark-Max".
        gen_prompt (str): The generated prompt for the model.
    Returns:
        output (str or None): The output from the model or None if invalid model choice.
    """
    if model_choice == "GPT-3.5":
        return call_openai_model(gen_prompt)
    elif model_choice == "Spark-Max":
        return call_sparkai_model(gen_prompt)
    elif model_choice == "glm-4-flash":
        return call_zhipuai_model(gen_prompt)
    elif model_choice == "DeepSeek-V2.5":
        return call_deepseek_model(gen_prompt)
    else:
        return None